# ******************************************************************************
#      Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
#      https://3d.bk.tudelft.nl/liangliang/
#
#      This file is part of Easy3D. If it is useful in your research/work,
#      I would be grateful if you show your appreciation by citing it:
#      ------------------------------------------------------------------
#           Liangliang Nan.
#           Easy3D: a lightweight, easy-to-use, and efficient C++ library
#           for processing and rendering 3D data.
#           Journal of Open Source Software, 6(64), 3255, 2021.
#      ------------------------------------------------------------------
#
#      Easy3D is free software; you can redistribute it and/or modify
#      it under the terms of the GNU General Public License Version 3
#      as published by the Free Software Foundation.
#
#      Easy3D is distributed in the hope that it will be useful,
#      but WITHOUT ANY WARRANTY; without even the implied warranty of
#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#      GNU General Public License for more details.
#
#      You should have received a copy of the GNU General Public License
#      along with this program. If not, see <http://www.gnu.org/licenses/>.
# ******************************************************************************

# - Config file for the EASY3D package
#
# It defines the following variables:
#       EASY3D_INCLUDE_DIRS - include directories for EASY3D
#       EASY3D_LIBRARIES    - available Easy3D libraries
#       EASY3D_CGAL_SUPPORT - whether CGAL support is enabled
# NOTE: The recommended way to specify libraries and headers with CMake is to use the
#       target_link_libraries command. This command automatically adds appropriate include
#       directories, compile definitions, the position-independent-code flag, and links to
#       requested libraries.

include(CMakeFindDependencyMacro)
find_dependency(Threads)

# Compute paths
get_filename_component(EASY3D_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

set(EASY3D_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
message(STATUS "EASY3D_INCLUDE_DIRS: ${EASY3D_INCLUDE_DIRS}")

set(EASY3D_LIBRARIES "@CONF_EASY3D_LIBRARIES@")
message(STATUS "EASY3D_LIBRARIES: ${EASY3D_LIBRARIES}")

# Resolve dependencies for CGAL
if(POLICY CMP0057)
  cmake_policy(SET CMP0057 NEW)
endif()
if ("easy3d::algo_ext" IN_LIST EASY3D_LIBRARIES) # second arg is the CMake variable name (instead of value)
    set (EASY3D_CGAL_SUPPORT TRUE)
    find_dependency(CGAL QUIET)
    message(STATUS "EASY3D_CGAL_SUPPORT: ${EASY3D_CGAL_SUPPORT} (EASY3D was built with CGAL support)")
else()
    set (EASY3D_CGAL_SUPPORT FALSE)
    message(STATUS "EASY3D_CGAL_SUPPORT: ${EASY3D_CGAL_SUPPORT} (EASY3D was built without CGAL support)")
endif()

# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET easy3d_util AND
   NOT TARGET easy3d_core AND
   NOT TARGET easy3d_kdtree AND
   NOT TARGET easy3d_algo AND
   NOT TARGET easy3d_algo_ext AND
   NOT TARGET easy3d_fileio AND
   NOT TARGET easy3d_renderer AND
   NOT TARGET easy3d_gui AND
   NOT TARGET easy3d_viewer AND
   NOT EASY3D_BINARY_DIR)
  include("${EASY3D_CMAKE_DIR}/Easy3DTargets.cmake")
endif()